import {createRouter, createWebHistory} from "vue-router";
import Home from '@/views/Home.vue'
import Setting from '@/views/Setting.vue'
import HomePage from '@/HomePage.vue'
import Loading from '@/Loading.vue'
import Login from '@/Login.vue'
import Configuration from '@/views/configuration.vue'

let router = createRouter({
    history: createWebHistory(),
    strict: true,
    base: '/messageplus',
    routes: [
      {
        path: '/messageplus',
        name: 'loading',
        component: Loading,
        beforeEnter: (to, from, next) => {
          var apps = document.querySelector('#app')
          document.title = 'Message-Plus'
          apps.style = ''
          next();
        }
      },
      {
        path: '/messageplus/login',
        name: 'login',
        component: Login,
        beforeEnter: (to, from, next) => {
          var apps = document.querySelector('#app')
          document.title = 'Message-Plus'
          apps.style = ''
          next();
        }
      },
      {
        path: '/messageplus/home',
        name: 'Home',
        component: HomePage,
        children: [
          {
            path: '/messageplus/home',
            name: 'Home',
            component: Home,
            beforeEnter: (to, from, next) => {
              var apps = document.querySelector('#app')
              document.title = 'Message-Plus'
              apps.style = ''
              next();
            }
          },
          {
            path: '/messageplus/home/configuration',
            name: 'Configuration',
            component: Configuration,
            beforeEnter: (to, from, next) => {
              var apps = document.querySelector('#app')
              document.title = 'Message-Plus'
              apps.style = ''
              next();
            }
          },
          {
            path: '/messageplus/home/setting',
            name: 'Setting',
            component: Setting,
            beforeEnter: (to, from, next) => {
              var apps = document.querySelector('#app')
              document.title = 'Message-Plus'
              apps.style = ''
              next();
            }
          }
        ],
        beforeEnter: (to, from, next) => {
          var apps = document.querySelector('#app')
          document.title = 'Message-Plus'
          apps.style = ''
          next();
        }
      },
    ]
})

export default router;